package java9_22.Test1;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class Weather {
    public static void main(String[] args) {
        Socket s=null;
        Scanner in=new Scanner(System.in);
        try {
            s=new Socket("localhost",9999);
            InputStream i = s.getInputStream();
            BufferedReader b=new BufferedReader(new InputStreamReader(i));
            OutputStream o = s.getOutputStream();
            PrintWriter p=new PrintWriter(o);
            while (true){
                String s1 = b.readLine();
                System.out.println(s1);
                String s2 = in.next();
                p.println(s2);
                p.flush();
                String s3=b.readLine();
                System.out.println(s3);
                if (s2.equals("5")){
                    break;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                s.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
